/*
 * @Author: your name
 * @Date: 2020-07-23 22:07:51
 * @LastEditTime: 2020-07-24 23:21:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \react_app\src\store\index.js
 */

import {createStore,combineReducers,applyMiddleware,compose} from 'redux'
import reduxThunk from 'redux-thunk' //中间件  可以让action 返回一个方法
import todeReducer from './todo_reducer'
import demoReducers from './demo_reducer'

const appReducers = combineReducers({
  todeReducer,
  demoReducers
})
//增强函数
const composeEnhancers =   window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
//composeEnhancers 调用后 ---在调用applyMiddleware(reduxThunk)
const enhancer = composeEnhancers(applyMiddleware(reduxThunk))

const store = createStore(
  appReducers,
  enhancer
)
//window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
export default store
